package com.easy.service.impl;

import com.easy.bean.Bookshelf;
import com.easy.mapper.BookshelfDao;
import com.easy.service.BookshelfService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookshelfServiceImpl implements BookshelfService {

    @Autowired
    BookshelfDao bookshelfDao;

    @Override
    public Bookshelf add(Bookshelf bookshelf) {
        bookshelfDao.add(bookshelf);
        Bookshelf result=bookshelfDao.one(bookshelf.getId());
        return  result;
    }

    @Override
    public int del(Integer id) {
        return bookshelfDao.del(id);
    }

    @Override
    public Bookshelf edit(Bookshelf bookshelf) {
        bookshelfDao.edit(bookshelf);
        Bookshelf result=bookshelfDao.one(bookshelf.getId());
        return result;
    }

    @Override
    public Bookshelf one(Integer id) {
        return bookshelfDao.one(id);
    }

    @Override
    public List<Bookshelf> all(Bookshelf bookshelf) {
        return bookshelfDao.all(bookshelf);
    }

    @Override
    public void page(Page page, Bookshelf bookshelf) {
        int count=bookshelfDao.pageCount(bookshelf);
        Object data=bookshelfDao.page(page,bookshelf);
        page.setCount(count);
        page.setData(data);

    }
}
